/*
 * @Description: loop
 * @Version: 3.0
 * @Autor: biao.hu
 * @Date: 2021-10-18 19:26:10
 * @LastEditors: biao.hu
 * @LastEditTime: 2021-10-18 19:30:24
 */
package loop

type Sub struct {
	Closing chan chan error
	Updates chan string
}

func (s *Sub) Close() error {
	err := make(chan error)
	s.Closing <- err
	return <-err
}

func (s *Sub) Loop() {
	var err error
	for {
		select {
		case errc := <-s.Closing:
			errc <- err
			close(s.Updates)
			return
		}
	}
}
